#ifndef MistagProbFunctions_h

#define MistagProbFunctions_h

// these mistag functions are for TCHP>6
double pMistagUds(double pt) {
  const int np=5;
  const double xLow=10;
  double p[np];
  if (pt<xLow)  return 0;
  p[0]         = 2.87743443e-05;
  p[1]         = -5.943559651e-07;
  p[2]         = 8.185319684e-08;
  p[3]         = -1.043944539e-10;
  p[4]         = 4.426895922e-14;
  float result = p[np-1];
  for (int ii=np-2; ii>-1; --ii) {
    result = result * pt + p[ii];
  }
  if (result<0)  return 0;
  return result;
}

double pMistagC(double pt) {
  const int np=6;
  const double xLow=10;
  double p[np];
  if (pt<xLow)  return 0;
  p[0]         = -0.003353098493;
  p[1]         = 0.000403517904;
  p[2]         = -2.139518615e-06;
  p[3]         = 4.687935515e-09;
  p[4]         = -4.49839048e-12;
  p[5]         = 1.566688446e-15;
  float result = p[np-1];
  for (int ii=np-2; ii>-1; --ii) {
    result = result * pt + p[ii];
  }
  if (result<0)  return 0;
  return result;
}

double pMistagB(double pt) {
  const int np=7;
  const double xLow=10;
  double p[np];
  if (pt<xLow)  return 0;
  p[0]         = -0.08161960837;
  p[1]         = 0.009050423712;
  p[2]         = -6.307349214e-05;
  p[3]         = 2.046584144e-07;
  p[4]         = -3.545918871e-10;
  p[5]         = 3.144706017e-13;
  p[6]         = -1.11770365e-16;
  float result = p[np-1];
  for (int ii=np-2; ii>-1; --ii) {
    result = result * pt + p[ii];
  }
  if (result<0)  return 0;
  return result;
}



#endif
